package com.example.showcase.common;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.concurrent.atomic.AtomicLong;

public class ChannelStatInfo implements Serializable {

    private static final long serialVersionUID = 377860132830060812L;

    /**
     * 客户端IP
     */
    private String clientIp;

    /**
     * server_local_port
     */
    private int port;
    /**
     * 重连次数
     */
    private int reConnCount;
    /**
     * 解码失败数
     */
    private int decodeFailCount;
    /**
     * 用户ID
     */
    private String userId;
    /**
     * 用户token
     */
    private String token;

    /**
     * 统计开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date gmtCreate;

    /**
     * 已接收字节数
     */
    private AtomicLong receivedBytes;
    /**
     * 已接收业务包
     */
    private AtomicLong receivedPackets;
    /**
     * 已接收TCP包
     */
    private AtomicLong receivedTcps;

    /**
     * 平均每个TCP包接收的字节数
     */
    private double bytesPerTcpReceive;
    /**
     * 平均每个TCP包接收的业务包
     */
    private double packetsPerTcpReceive;

    /**
     * 已处理的字节数
     */
    private AtomicLong handledBytes;
    /**
     * 已处理的业务包
     */
    private AtomicLong handledPackets;

    /**
     * 已发送的字节数
     */
    private AtomicLong sentBytes;
    /**
     * 已发送的业务包
     */
    private AtomicLong sentPackets;

    /**
     * 最近一次通信时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date gmtLatestCommunicate;

    public String getClientIp() {
        return clientIp;
    }

    public void setClientIp(String clientIp) {
        this.clientIp = clientIp;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public int getReConnCount() {
        return reConnCount;
    }

    public void setReConnCount(int reConnCount) {
        this.reConnCount = reConnCount;
    }

    public int getDecodeFailCount() {
        return decodeFailCount;
    }

    public void setDecodeFailCount(int decodeFailCount) {
        this.decodeFailCount = decodeFailCount;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public Date getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(Date gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public AtomicLong getReceivedBytes() {
        return receivedBytes;
    }

    public void setReceivedBytes(AtomicLong receivedBytes) {
        this.receivedBytes = receivedBytes;
    }

    public AtomicLong getReceivedPackets() {
        return receivedPackets;
    }

    public void setReceivedPackets(AtomicLong receivedPackets) {
        this.receivedPackets = receivedPackets;
    }

    public AtomicLong getReceivedTcps() {
        return receivedTcps;
    }

    public void setReceivedTcps(AtomicLong receivedTcps) {
        this.receivedTcps = receivedTcps;
    }

    public double getBytesPerTcpReceive() {
        return bytesPerTcpReceive;
    }

    public void setBytesPerTcpReceive(double bytesPerTcpReceive) {
        this.bytesPerTcpReceive = bytesPerTcpReceive;
    }

    public double getPacketsPerTcpReceive() {
        return packetsPerTcpReceive;
    }

    public void setPacketsPerTcpReceive(double packetsPerTcpReceive) {
        this.packetsPerTcpReceive = packetsPerTcpReceive;
    }

    public AtomicLong getHandledBytes() {
        return handledBytes;
    }

    public void setHandledBytes(AtomicLong handledBytes) {
        this.handledBytes = handledBytes;
    }

    public AtomicLong getHandledPackets() {
        return handledPackets;
    }

    public void setHandledPackets(AtomicLong handledPackets) {
        this.handledPackets = handledPackets;
    }

    public AtomicLong getSentBytes() {
        return sentBytes;
    }

    public void setSentBytes(AtomicLong sentBytes) {
        this.sentBytes = sentBytes;
    }

    public AtomicLong getSentPackets() {
        return sentPackets;
    }

    public void setSentPackets(AtomicLong sentPackets) {
        this.sentPackets = sentPackets;
    }

    public Date getGmtLatestCommunicate() {
        return gmtLatestCommunicate;
    }

    public void setGmtLatestCommunicate(Date gmtLatestCommunicate) {
        this.gmtLatestCommunicate = gmtLatestCommunicate;
    }

    @Override
    public String toString() {
        return "ChannelStatInfo{" +
                "clientIp='" + clientIp + '\'' +
                ", port=" + port +
                ", reConnCount=" + reConnCount +
                ", decodeFailCount=" + decodeFailCount +
                ", userId='" + userId + '\'' +
                ", token='" + token + '\'' +
                ", gmtCreate=" + gmtCreate +
                ", receivedBytes=" + receivedBytes +
                ", receivedPackets=" + receivedPackets +
                ", receivedTcps=" + receivedTcps +
                ", bytesPerTcpReceive=" + bytesPerTcpReceive +
                ", packetsPerTcpReceive=" + packetsPerTcpReceive +
                ", handledBytes=" + handledBytes +
                ", handledPackets=" + handledPackets +
                ", sentBytes=" + sentBytes +
                ", sentPackets=" + sentPackets +
                ", gmtLatestCommunicate=" + gmtLatestCommunicate +
                '}';
    }
}
